package com.example.demo;

import java.util.Observable;

/**
 * jdk提供的一种观察者的实现方式，被观察者
 * Created by Easettle
 * Date:2021-02-18 15:43
 * Email:easettle@qq.com
 */
public class Easettle extends Observable {
    private String name = "Easettle社区";
    private static Easettle easettle = null;

    private Easettle() {}

    public static Easettle getInstance() {
        if (null == easettle) {
            easettle = new Easettle();
        }
        return easettle;
    }

    public String getName() {
        return name;
    }

    public void publishQuestion(Question question) {
        System.out.println(question.getUserName() + "在"+ this.name+"上提交一个问题。");
        setChanged();
        notifyObservers(question);
    }
}
